home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / comms / other / dc-sx107install / sx / developer / sasc / example2.c < prev    next >
C/C++ Source or Header  |  1999-11-29  |  2KB  |  91 lines

  1. /*
  2.  
  3. ----------------------------------------------------------
  4.  System-X door using EXEC-MESSAGES (The prefered method!)
  5. ----------------------------------------------------------
  6.  
  7. See the botton of this source!
  8.  
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <stdlib.h>
  14. #include <proto/exec.h>
  15. #include <proto/dos.h>
  16.  
  17. struct MsgPort *bbsport;
  18.  
  19. struct JHMessage
  20. {
  21.     struct    Message Msg;
  22.     char    String[200];
  23.     long    Data,
  24.         Command;
  25. } themsg;
  26.  
  27.  
  28. void PS(char * str);
  29. void XIMFunction(int func, long data, char * str);
  30. void Door(void);
  31.  
  32. BOOL sx;
  33.  
  34.  
  35. int main(int argc, char *argv[])
  36. {
  37.     if(!argv[1] || argv[1][0]==0)
  38.         PutStr("This program requires System-X BBS Software\n");
  39.     else {
  40.         sprintf(buf, "AEDoorPort%s", argv[1]);
  41.         bbsport = FindPort(buf);
  42.         if(bbsport)
  43.         {
  44.             XIMFunction(1, 0, 0);     /* function 1 = register */
  45.  
  46.             /* find out if we are under SYSTEM-X or AmiExpress */
  47.  
  48.             if(strcmp(themsg.String,"SX")==0) sx=TRUE; else sx=FALSE;
  49.  
  50.             Door();
  51.  
  52.             XIMFunction(2, 0, 0);     /* function 2 = shutdown */
  53.         }
  54.     }
  55. }
  56.  
  57. void PS(char * str)
  58. {
  59.     if(sx) XIMFunction(1500, (long)str, 0); else XIMFunction(4, 0, str);
  60. }
  61.  
  62. void XIMFunction(int func, long data, char * str)
  63. {
  64.     struct MsgPort *replyport;
  65.  
  66.     replyport = CreateMsgPort();
  67.     if(replyport)
  68.     {
  69.         themsg.Msg.mn_Length    = sizeof(struct JHMessage);
  70.         themsg.Msg.mn_ReplyPort    = replyport;
  71.         themsg.Data         = data;
  72.         themsg.Command         = func;
  73.         if(str && str[0]!=0) strcpy(themsg.String, str);
  74.         PutMsg(bbsport, (struct Message *)&themsg);
  75.         WaitPort(replyport);
  76.         GetMsg(replyport);
  77.         DeleteMsgPort(replyport);
  78.     }
  79. }
  80.  
  81. /* ============ PUT YOUR DOOR IN HERE ============== */
  82.  
  83. void Door(void)
  84. {
  85.     PS("Hello! Welcome to a test door\r\n\r\n");
  86.     XIMFunction(5, 40, "Please enter some text: ");
  87.     PS("\r\n\r\nYou entered: ");
  88.     PS(themsg.String);
  89.     PS("\r\n\r\nExiting...\r\n\r\n");
  90. }
  91.